import axiosInstance from '../utils/request.js'

export const courseApi = {

    getCoursesInfos() {
        return axiosInstance.get('/course')
    },
    getCourseBetweenDates(start_time, end_time, location)
    {
        return axiosInstance.get('/course/duration', {
            params: {
                'start_time': start_time,
                'end_time': end_time,
                'location': location
            }
        })
    },
    getCouseThisWeek(location) {
        return axiosInstance.get('/course/thisweek', {
            params: {
              
                'location': location
            }
        })
    },



    /**
     {
        "jobNumber": "104444",
        "courseName": "java课程设计",
        "courseSession": "2023秋季学期",
        "contain": 59,
        "studentNumber": 99,
        "campus": "曲江",
        "position": "一号机房",
        "courseDate": [
        "1991-03-18"
    ]
    }
     * @returns Promise
     */
//    async addCourse(id,name,session,contain,studentnumber,campus,position,coursedates)
//     {
//         return await axiosInstance.post('/course/add',  {
//             'jobNumber': id,
//             'courseName': name,
//             'courseSession': session,
//             "contain": contain,
//             "studentNumber": studentnumber,
//             "campus": campus,
//             "position": position,
//             "courseDate":coursedates
//         })
//     },
     getAllCourseInfos(sid,campus) {
        return axiosInstance.get('/course/infos', {
            params:{
                sid,
                campus,
            }
        })
    },
     getAllCourseHome(sid, campus) {
        return axiosInstance.get('/course/class', {
            params: {
                sid,
                campus,
            }
        })
    },
    addCourse(courses) {
         return axiosInstance.post('/course',courses)
    },
    removeCourse(course) {
        return axiosInstance.delete('/course', {
            data: { ...course }
        })
    },
    removeCourseMul(courses) {
        return axiosInstance.delete('/course/mul', {
          data:courses
      })  
    },
    updateCourse(course) {
        return axiosInstance.put('/course',course)
    },
    updateCourseMul(courses) {
        return axiosInstance.put('/course/mul',courses)
    }

}